using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration; using Sispe.Entities;

namespace Sispe.Repository.Mapping
{
    public class SOCIOMap : EntityTypeConfiguration<SOCIO>
    {
        public SOCIOMap()
        {
            // Primary Key
            this.HasKey(t => t.IdSocio);

            // Properties
            this.Property(t => t.Ruc)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.RazonSocial)
                .IsRequired()
                .HasMaxLength(350);

            // Table & Column Mappings
            this.ToTable("SOCIO");
            this.Property(t => t.IdSocio).HasColumnName("IdSocio");
            this.Property(t => t.IdTipoSocio).HasColumnName("IdTipoSocio");
            this.Property(t => t.Ruc).HasColumnName("Ruc");
            this.Property(t => t.RazonSocial).HasColumnName("RazonSocial");

            // Relationships
            this.HasRequired(t => t.TIPO_SOCIO)
                .WithMany(t => t.SOCIOs)
                .HasForeignKey(d => d.IdTipoSocio);

        }
    }
}
